﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SysMenuInfoList.aspx.cs" Inherits="JYH.Web.MES.SYS.UI.SysMenuInfoList" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
        <script type="text/javascript">
            $(function () {

            $('#tt').treegrid({
                iconCls: 'icon-xiangmu',
                url: '/api/SYS/QueryMenuToTreeGrid',
                height: document.documentElement.clientHeight - 100,
                method: 'get',
                idField: 'MenuID',
                treeField: 'MenuName',
                checkbox: true,
                rownumbers: true,
                animate: true,
                collapsible: true,
                pagination: true,
                fitColumns: true,
                scrollbarSize: 0,
                columns: [[
                    { field: 'MenuID', hidden: true },
                    { field: 'MenuName', title: 'MenuName', width: 200 },
                    { field: 'UpMenuID', hidden: true },
                    { field: 'MenuType', hidden: true },
                    { field: 'MenuNO', title: 'MenuNO', width: 120 },
                    { field: 'MenuUrl', title: 'MenuUrl', width: 250 },
                    { field: 'MenuTypeName', title: 'MenuTypeName', width: 100 },
                    { field: 'ClassName', title: 'ClassName', width: 100 },
                    { field: 'NameSpace', title: 'NameSpace', width: 100 },
                    { field: 'IconName', title: 'IconName', width: 100 },
                    
                    {
                        field: 'RState', title: 'State', width: 80, align: 'center', formatter: function (val, rec) {
                            return val == "0" ? "<span class=\"red\">Editing</span>" : val == "1" ? "Approved" : "<span class=\"red\">Unknow</span>";
                        }},
                    {
                        field: 'Opt', title: "", width: 220, align: 'center', formatter: function (val, rec) {

                            if (rec.UpMenuID == null) {
                                return "<span class='morebtn'><a name='lock' href='#' style='color:#a61c00' onclick=\"InsertMenu('" + rec.MenuID + "')\">[Submenu]</a>&nbsp; | &nbsp;" +
                                    "<span class='morebtn'> <a name='lock' href='#' style='color:#ff0000' onclick=\"UpdateOpen('" + rec.MenuID + "')\">[Update]</a> &nbsp;";
                            }
                            else
                            {
                                return "<span class='morebtn'> <a name='lock' href='#' style='color:#ff0000' onclick=\"UpdateOpen('" + rec.MenuID + "')\">[Update]</a> &nbsp;";
                            }
                         
                        }
                    }
                ]],
                onClickRow: function (row) {
                    // 点击行时切换展开/折叠状态
                    $('#tt').treegrid('toggle', row.MenuID);
                },
                onSortColumn: function (sort, order) {
                    $("#hSort").val(sort);
                    $("#rowName").val(order);
                    loadLocal();
                }
            });
            //SyntaxError: Unexpected token 'S',
            $(window).resize(function () {
                $('#tt').treegrid('resize');
            });

        })
        //新增菜单
            function AddNew() {
                return OpenWindow("Menu Information", "SYS/UI/SysMenuInfoEdit.aspx?UpMenuID=", 780, 350, function () {
                $("#tt").treegrid("reload");
            });
        }
        //子菜单新增
        function InsertMenu(MenuID) {
            return OpenWindow("Menu Information", "SYS/UI/SysMenuInfoEdit.aspx?UpMenuID=" + MenuID, 780, 350, function () {
                $("#tt").treegrid("reload");
            });
        }
        //修改
        function UpdateOpen(MenuID) {

            return OpenWindow("Menu Information ", "SYS/UI/SysMenuInfoEdit.aspx?MenuID=" + MenuID, 780, 350,
                function () { $('#tt').treegrid("reload"); })
        }
        //删除
            function Delete() {
            var id = GetDataGridSelectedRow('tt', 'MenuID');
            if (id == "") {
                Alert("Please select one before deleting！");
                return false;
            }
            Confirm("确定要删除吗？", function () {
                var Info =
                {
                    MenuID: id
                    
                }
                var url = "../../api/SYS/DeleteMenuInfo";
                DataService.PostJson(url, Info, function (error, response) {

                    Alert(response.Message);
                    $('#tt').treegrid("reload"); 

                })
            });
        }
      

        </script>
</head>
<body>
    <form id="form1" runat="server">

        <div class="pagebox">
            <div class="cbox">
                <!--工具栏-->
                <div class="easyui-panel" style="padding: 15px; width: 100%;">
                    <div id="tb">
                        <div>
                            <a href="#" class="easyui-linkbutton c1" data-options="iconCls:'icon-tianjia'" onclick="AddNew()">AddNew</a>
                             <a href="#" class="easyui-linkbutton c2" data-options="iconCls:'icon-buchongiconsvg13'" onclick="Delete()">Delete</a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="cbox">
                <table title="MenuInfo List" style="width: 100%;" id="tt">     
                </table>
            </div>
        </div>
    </form>
</body>
</html>
